home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / net / squid-1.1.22 / cntl / ccs
Text File  |  1998-07-26  |  4KB  |  125 lines

  1. #!/bin/sh
  2. #
  3. # Postinstallscript written by Ron Record (rr@sco.com) for use with my
  4. # UnixWare 7 packaging of Squid. Just need to setup the Squid configuration
  5. # file with the right hostname and initialize the cache. Also output a
  6. # message about using Squid as an HTTP accelerator.
  7.  
  8. scriptname="$0"
  9. step="$1"
  10. keywords="$2"
  11. pkglist="$3"
  12.  
  13. # Source in the standard functions library, ccsSetup.sh
  14. . ccsSetup.sh
  15.  
  16. #############################################################################
  17. #
  18. # enable_squid
  19. #
  20. # enable the preconfigured server, as a default
  21. #############################################################################
  22. enable_squid()
  23. {
  24.     if [ -x /etc/squid ]; then
  25.         /etc/squid enable
  26.     fi
  27. }
  28.  
  29. #############################################################################
  30. #
  31. # HOST_set
  32. #         fixup the HOST name in any configuration files
  33. #
  34. #############################################################################
  35. HOST_set()
  36. {
  37.   HOSTPROG=/usr/bin/hostname
  38.   if [ -x $HOSTPROG ] 
  39.   then
  40.     HOSTNAME=`$HOSTPROG`
  41.   else
  42.     HOSTNAME=localhost
  43.   fi
  44.   [ "$HOSTNAME" ] || HOSTNAME=localhost
  45.   HOST_FILES="/usr/local/squid/etc/squid.conf"
  46.   for i in $HOST_FILES
  47.   do
  48.   [ -f $i ] && {
  49.     sed -e "s/foo.bar.spam.com/$HOSTNAME/g" < $i > /tmp/_ccs$$
  50.     mv /tmp/_ccs$$ $i
  51.     rm -f /tmp/_ccs$$
  52.     chown root:sys $i
  53.   }
  54.   done
  55. }
  56.  
  57. doPostExport() {
  58. # edit configuration file
  59. HOST_set
  60.  
  61. # Stop and restart the Netscape FastTrack server on port 80, if it's running
  62. FAST=
  63. ps -ef | grep /usr/internet/ns_httpd/httpd-80 > /dev/null && {
  64.          /usr/internet/ns_httpd/httpd-80/stop > /dev/null 2>&1
  65.          FAST=1
  66. }
  67. # Initialize the cache
  68. /usr/local/squid/bin/squid -z > /dev/null 2>&1
  69.  
  70. # Configure for automatic startup when going multi-user
  71. if [ "$FAST" ]
  72. then
  73.     echo "In order to enable Squid, you will need to first disable the
  74. Netscape FastTrack server running on port 80. After doing so, run the
  75. commands (as root):
  76.      /etc/squid enable
  77.      /etc/squid start"
  78. else
  79.     enable_squid
  80. fi
  81.  
  82. # Tell the user what we're configured for
  83. echo "
  84. This release of Squid is pre-configured to act as an HTTP accelerator.
  85. As such, it runs on port 80 and caches requests to the 'real' server
  86. running on port 8080. These parameters can be configured by editing
  87. /usr/local/squid/etc/squid.conf. In addition, the Apache web server
  88. contained elsewhere in this distribution is configured by default to
  89. run on port 8080. Thus, you can install these preconfigured versions
  90. of Squid and Apache and they should 'just work'.
  91.  
  92. If you already have a server running on port 80 (e.g. the Netscape FastTrack
  93. server), you will need to disable that or reconfigure Squid prior to starting
  94. Squid. In addition to the Squid binary distribution, this package also
  95. contains the Squid User's Guide which has been installed in the Apache
  96. web server's default document root (/usr/local/lib/apache/share/htdocs/squid).
  97. To access it, after installing Squid and Apache, open :
  98. http://your.host.name/squid/
  99.  
  100. Squid has been configured to start automatically every time the system goes 
  101. multi-user. To start Squid now, execute the command '/etc/squid start' after
  102. the successful completion of this installation. "
  103.  
  104. [ "$FAST" ] && /usr/internet/ns_httpd/httpd-80/start > /dev/null 2>&1
  105. }
  106.  
  107. DisableStop()
  108. {
  109.     /etc/squid disable > /dev/null 2>&1
  110.     /etc/squid stop > /dev/null 2>&1
  111. }
  112.  
  113. ccs_return_value=0
  114.  
  115. case "$step" in
  116.         POST_EXPORT) doPostExport ;;
  117.         PRE_UNEXPORT) DisableStop ;;
  118.         POST_UNEXPORT) rm -f /etc/rc2.d/S97squid ;;
  119. esac
  120.  
  121. exit $ccs_return_value
  122.  
  123.